package com.example.system.class18;

import java.util.ArrayList;
import java.util.List;

public class Code01_PrintAllSubSequence {
    public static void main(String[] args) {
        System.out.println(getAllSubSequence("ABC"));

    }

    public static List<String> getAllSubSequence(String str) {
        if (str == null || str.length() == 0) {
            return null;
        }
        List<String> ans = new ArrayList<>();
        char[] chars = str.toCharArray();
        process(chars, "", 0, ans);
        return ans;
    }


    public static void process(char[] chars, String path, Integer index, List<String> ans) {
        if (index == chars.length) {
            ans.add(path);
            return;
        }
        // index 位置
        String yes = path + chars[index];
        System.out.printf("index:%d,chars[%d]:%c\n", index, index, chars[index]);
        index++;
        // 不要index位置的
        process(chars, path, index, ans);
        // 要index位置的
        process(chars, yes, index, ans);
    }
}
